//app.js
import Ajax from "./utils/ajax"
import Api from "./utils/api"
import { loginwx } from "./utils/util"

App({
  onLaunch: function () {
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    
    loginwx().then(res=>{
      this.globalData.openid = res
    })

    // 查询通知公告
    setTimeout(()=>{
      if(this.globalData.notice){
        return;
      }
      Ajax.get(Api.wx.getSys,{code:'WeXinNotice'}).then(res=>{
        this.globalData.notice = res.value
        if (this.sysReadyCallback) {
          this.sysReadyCallback(res.value)
        }
      })
    },6000)
  },
  globalData: {
    userInfo: wx.getStorageSync('userInfo'), // 从本地缓存中获取用户信息
    openid: '',
    signNumber: -1, // 今日打卡数 -1初始化状态
    addressInfo:{}, // 位置信息
    notice:'' // 通知公告
  }
})